home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cocktail
/
cg.lha
/
cg
/
src
/
c5.puma
< prev
next >
Wrap
Text File
|
1992-11-24
|
21KB
|
643 lines
/* Ich, Doktor Josef Grosch, Informatiker, 27.3.1992 */
TRAFO EvalC3
TREE Tree
PUBLIC EvalImplC ToBit0
GLOBAL {
FROM SYSTEM IMPORT ADR, TSIZE;
FROM General IMPORT Max;
FROM DynArray IMPORT MakeArray;
FROM IO IMPORT WriteS, WriteNl, WriteI, WriteB, StdOutput;
FROM Texts IMPORT WriteText;
FROM Sets IMPORT tSet, MakeSet, ReleaseSet, Include, Exclude, Minimum,
Maximum, IsElement, WriteSet, IsEmpty, Extract;
FROM Relations IMPORT IsRelated;
FROM TreeC1 IMPORT BSS;
FROM TreeC2 IMPORT GetIterator, Iterator, WriteLine;
FROM EvalC IMPORT Class;
FROM Errors IMPORT Error, Short, MessageI;
FROM Positions IMPORT NoPosition;
IMPORT EvalC;
FROM Tree IMPORT
NoTree , tTree , Referenced , NoCodeClass ,
Computed , Reverse , Write , Read ,
Inherited , Synthesized , Input , Output ,
Virtual , Test , Left , Right ,
HasOutput , NonBaseComp , Dummy , Trace ,
Demand , Funct , NoClass , Options ,
TreeRoot , iModule , iMain , itTree ,
ForallClasses, ForallAttributes, f , WI , WN ,
ClassCount , IdentifyClass , IdentifyAttribute,
tBitIndex , tBitInfo , iNoTree , QueryTree ;
VAR
i, i2, j, k, n, MaxBit, MaxInstCount, Check: SHORTCARD;
Node, Attr, ChildsClass : tTree;
Success, IsStable : BOOLEAN;
BitIndexSize : LONGINT;
gBitIndex : tBitIndex;
InhIndices : tSet;
InhIndexSize : LONGINT;
InhIndexCount : POINTER TO ARRAY [1..1000000] OF SHORTCARD;
PROCEDURE GenCall (t: tTree; j: SHORTCARD);
BEGIN
WITH t^.Class.Instance^ [j] DO
IF ({Synthesized, Left} <= Properties) THEN
k := ToBit0 (t, j);
!IFNOTIN (! WN (k MOD BSS); !, yyt->yyHead.yyIsComp! WN (k DIV BSS); !) !
!yyS! WN (k); ! (yyt); /* ! WI (Attribute^.Child.Name); ! */ }!
ELSIF ({Inherited, Left} <= Properties) THEN
k := ToBit0 (t, j);
!IFNOTIN (! WN (k MOD BSS); !, yyt->yyHead.yyIsComp! WN (k DIV BSS); !) !
IF IsElement (ORD ('Z'), Options) AND (Trace IN t^.Class.Properties) THEN
!yyVisitParent (yyt); !
!yyI [yyt->yyHead.yyOffset + ! WN (k); !](yyt->yyHead.yyParent); /* !
WI (Attribute^.Child.Name); ! */ !
@yyWriteVisit (yyt->yyHead.yyParent, "?"); }@
ELSE
!yyI [yyt->yyHead.yyOffset + ! WN (k); !](yyt->yyHead.yyParent); /* !
WI (Attribute^.Child.Name); ! */ }!
END;
ELSIF ({Inherited, Right} <= Properties) THEN
k := ToBit1 (Selector, j - t^.Class.AttrCount - Selector^.Child.InstOffset);
!IFNOTIN (! WN (k MOD BSS); !, yyt->! WI (Class^.Class.Name);
!.! WI (Selector^.Child.Name); !->yyHead.yyIsComp! WN (k DIV BSS); !) !
k := ToBit2 (t, Selector, j);
!yyI! WN (k); ! (yyt); /* ! WI (Selector^.Child.Name);
!:! WI (Attribute^.Child.Name); ! */ }!
ELSIF ({Synthesized, Right} <= Properties) THEN
k := ToBit1 (Selector, j - t^.Class.AttrCount - Selector^.Child.InstOffset);
!IFNOTIN (! WN (k MOD BSS); !, yyt->! WI (Class^.Class.Name);
!.! WI (Selector^.Child.Name); !->yyHead.yyIsComp! WN (k DIV BSS); !) !
IF IsElement (ORD ('Z'), Options) AND (Trace IN t^.Class.Properties) THEN
@yyWriteVisit (yyt, "@ WI (Selector^.Child.Name); @"); @
!yyS! WN (k);
! (yyt->! WI (Class^.Class.Name); !.! WI (Selector^.Child.Name);
!); /* ! WI (Selector^.Child.Name); !:! WI (Attribute^.Child.Name); ! */ !
!yyVisitParent (yyt->! WI (Class^.Class.Name); !.! WI (Selector^.Child.Name); !); }!
ELSE
!yyS! WN (k);
! (yyt->! WI (Class^.Class.Name); !.! WI (Selector^.Child.Name);
!); /* ! WI (Selector^.Child.Name); !:! WI (Attribute^.Child.Name); ! */ }!
END;
END;
END;
END GenCall;
PROCEDURE GenEvalAttr (t: tTree; i: INTEGER);
BEGIN
Class := t;
WITH t^.Class.Instance^ [i] DO
IF IsElement (ORD ('X'), Options) AND (Trace IN t^.Class.Properties) THEN
@yyWriteEval (yyt, "@ WI (Attribute^.Child.Name); @");@
IF (Action # ADR (Action)) AND NOT (Virtual IN Properties) THEN
EvalC.GenEvaluator (Action); !!
IF Test IN Properties THEN
!writebool (yyb) yyWriteNl ();!
ELSIF (Attribute^.Kind = Tree.Child) OR (Attribute^.Attribute.Type = itTree) THEN
!write! WI (itTree);
! (yyt->! WI (t^.Class.Name); !.! WI (Attribute^.Child.Name); !)!
ELSE
!write! WI (Attribute^.Child.Type);
! (yyt->! WI (t^.Class.Name); !.! WI (Attribute^.Child.Name); !) yyWriteNl ();!
END;
ELSE
!yyWriteNl ();!
END;
ELSIF IsElement (ORD ('Y'), Options) AND (Trace IN t^.Class.Properties) THEN
@yyWriteEval (yyt, "@ WI (Attribute^.Child.Name); @");@
IF (Action # ADR (Action)) AND NOT (Virtual IN Properties) THEN
EvalC.GenEvaluator (Action);
END;
ELSE
IF (Action # ADR (Action)) AND NOT (Virtual IN Properties) THEN
EvalC.GenEvaluator (Action);
END;
END;
END;
END GenEvalAttr;
}
PROCEDURE EvalImplC (t: Tree)
Ag (..) :- {
MaxBit := 0;
MaxInstCount := 0;
ForallClasses (Classes, CompBitInfo);
MakeSet (InhIndices, MaxInstCount);
InhIndexSize := MaxInstCount;
MakeArray (InhIndexCount, InhIndexSize, TSIZE (SHORTCARD));
FOR i := 1 TO MaxInstCount DO InhIndexCount^ [i] := 0; END;
ForallClasses (Classes, CompInhIndices);
@# define IFNOTIN(b, s) if (! (s & 1 << b)) {@
!# define INCL(s, b) s |= 1 << b!
!# define REMOTE_SYN(i, b, c, n, t, a) (n->yyHead.i & 1 << b ? (void) 0 : c (n), n->t.a)!
!# define REMOTE_INH(i, b, k, n, t, a) (n->yyHead.i & 1 << b ? (void) 0 : yyI [n->yyHead.yyOffset + k](n->yyHead.yyParent), n->t.a)!
EvalC.EvalImplHead (t);
!!
!static void yyE ARGS((register ! WI (itTree); ! yyt));!
FOR i := 1 TO MaxBit - 1 DO
!static void yyS! WN (i); ! ARGS((register ! WI (itTree); ! yyt));!
END;
FOR i := Minimum (InhIndices) TO Maximum (InhIndices) DO
IF IsElement (i, InhIndices) THEN
!static void yyI! WN (i); ! ARGS((register ! WI (itTree); ! yyt));!
END;
END;
!!
!static ! WI (iMain); !_tProcTree yyI [! WN (Maximum (InhIndices) + 1); !] = { 0,!
FOR i := 1 TO Maximum (InhIndices) DO
IF IsElement (i, InhIndices) THEN
! yyI! WN (i); !,!
ELSE
! 0,!
END;
END;
!};!
!!
!static void yyAbort!
!# if defined __STDC__ | defined __cplusplus!
! (! WI (itTree); ! yyt)!
!# else!
! (yyt) ! WI (itTree); ! yyt;!
!# endif!
!{!
@ (void) fprintf (stderr, "Error: module @ WI (EvalName); @, cyclic dependencies\n");@
! ! WI (iMain); !_Exit ();!
!}!
!!
!void ! WI (EvalName); !!
!# if defined __STDC__ | defined __cplusplus!
! (! WI (itTree); ! yyt)!
!# else!
! (yyt) ! WI (itTree); ! yyt;!
!# endif!
IF NOT IsElement (ORD ('9'), Options) THEN
!{ Init! WI (iModule); ! (yyt); yyE (yyt); }!
ELSE
!{!
! char xxHigh;!
! xxStack = 1000000000;!
! Init! WI (iModule); ! (yyt); yyE (yyt);!
@ (void) printf ("Stacksize %d\n", (int) & xxHigh - xxStack);@
!}!
END;
!!
REPEAT IsStable := TRUE; ForallClasses (Classes, CompOutput); UNTIL IsStable;
!static void yyE!
!# if defined __STDC__ | defined __cplusplus!
! (register ! WI (itTree); ! yyt)!
!# else!
! (yyt) register ! WI (itTree); ! yyt;!
!# endif!
!{!
WriteLine (TreeRoot^.Ag.EvalCodes^.Codes.LocalLine);
WriteText (f, TreeRoot^.Ag.EvalCodes^.Codes.Local);
Node := TreeRoot^.Ag.Modules;
WHILE Node^.Kind = Tree.Module DO
WriteLine (Node^.Module.EvalCodes^.Codes.LocalLine);
WriteText (f, Node^.Module.EvalCodes^.Codes.Local);
Node := Node^.Module.Next;
END;
IF IsElement (ORD ('9'), Options) THEN
! char xxLow;!
! xxStack = Min (xxStack, (int) & xxLow);!
END;
! for (;;) {!
! if (yyt == ! WI (iNoTree); ! || yyt->yyHead.yyIsComp0 & 1) return;!
! yyt->yyHead.yyIsComp0 |= 1;!
! switch (yyt->Kind) {!
ForallClasses (Classes, GenE);
! default: return;!
! }!
! }!
!}!
!!
FOR i := 2 TO MaxBit DO
n := 0; (* are there any SYN attributes ? *)
ForallClasses (Classes, CountSynAttr);
IF n > 0 THEN
!static void yyS! WN (i - 1); !!
!# if defined __STDC__ | defined __cplusplus!
! (register ! WI (itTree); ! yyt)!
!# else!
! (yyt) register ! WI (itTree); ! yyt;!
!# endif!
!{!
WriteLine (TreeRoot^.Ag.EvalCodes^.Codes.LocalLine);
WriteText (f, TreeRoot^.Ag.EvalCodes^.Codes.Local);
Node := TreeRoot^.Ag.Modules;
WHILE Node^.Kind = Tree.Module DO
WriteLine (Node^.Module.EvalCodes^.Codes.LocalLine);
WriteText (f, Node^.Module.EvalCodes^.Codes.Local);
Node := Node^.Module.Next;
END;
IF IsElement (ORD ('9'), Options) THEN
! char xxLow;!
! xxStack = Min (xxStack, (int) & xxLow);!
END;
IF IsElement (ORD ('5'), Options) THEN
! IFNOTIN (! WN ((i - 1) MOD BSS); !, yyt->yyHead.yyIsDone! WN ((i - 1) DIV BSS);
!) INCL (yyt->yyHead.yyIsDone! WN ((i - 1) DIV BSS); !, ! WN ((i - 1) MOD BSS); !); } else yyAbort (yyt);!
END;
IF n > 1 THEN
! switch (yyt->Kind) {!
ForallClasses (Classes, GenS);
! }!
ELSE
ForallClasses (Classes, GenS);
END;
! INCL (yyt->yyHead.yyIsComp! WN ((i - 1) DIV BSS); !, ! WN ((i - 1) MOD BSS); !);!
!}!
!!
END;
END;
FOR i := Minimum (InhIndices) TO Maximum (InhIndices) DO
IF IsElement (i, InhIndices) THEN
!static void yyI! WN (i); !!
!# if defined __STDC__ | defined __cplusplus!
! (register ! WI (itTree); ! yyt)!
!# else!
! (yyt) register ! WI (itTree); ! yyt;!
!# endif!
!{!
WriteLine (TreeRoot^.Ag.EvalCodes^.Codes.LocalLine);
WriteText (f, TreeRoot^.Ag.EvalCodes^.Codes.Local);
Node := TreeRoot^.Ag.Modules;
WHILE Node^.Kind = Tree.Module DO
WriteLine (Node^.Module.EvalCodes^.Codes.LocalLine);
WriteText (f, Node^.Module.EvalCodes^.Codes.Local);
Node := Node^.Module.Next;
END;
IF IsElement (ORD ('9'), Options) THEN
! char xxLow;!
! xxStack = Min (xxStack, (int) & xxLow);!
END;
Check := 0;
IF InhIndexCount^ [i] > 1 THEN
! switch (yyt->Kind) {!
ForallClasses (Classes, EvalImplC);
! }!
ELSE
ForallClasses (Classes, EvalImplC);
END;
IF Check # InhIndexCount^ [i] THEN
MessageI ("internal error in yyI", Error, NoPosition, Short, ADR (i));
END;
!}!
!!
END;
END;
!void Begin! WI (EvalName); ! ()!
!{!
WriteLine (EvalCodes^.Codes.BeginLine);
WriteText (f, EvalCodes^.Codes.Begin);
Node := Modules;
WHILE Node^.Kind = Tree.Module DO
WriteLine (Node^.Module.EvalCodes^.Codes.BeginLine);
WriteText (f, Node^.Module.EvalCodes^.Codes.Begin);
Node := Node^.Module.Next;
END;
!}!
!!
!void Close! WI (EvalName); ! ()!
!{!
WriteLine (EvalCodes^.Codes.CloseLine);
WriteText (f, EvalCodes^.Codes.Close);
Node := Modules;
WHILE Node^.Kind = Tree.Module DO
WriteLine (Node^.Module.EvalCodes^.Codes.CloseLine);
WriteText (f, Node^.Module.EvalCodes^.Codes.Close);
Node := Node^.Module.Next;
END;
!}!
}; .
Class (..) :-
NoCodeClass * Properties = {{}};
i <= InstCount;
a: SHORTCARD;
{ a := ToAttr (t, i);
IF a = 0 THEN RETURN; END;
WITH Instance^ [a] DO
IF {Inherited, Right} <= Properties THEN
Class := t;
IF InhIndexCount^ [i] > 1 THEN
! case k! WI (Name); !:!
END;
INC (Check);
k := ToBit1 (Selector, a - AttrCount - Selector^.Child.InstOffset);
IF IsElement (ORD ('5'), Options) THEN
! IFNOTIN (! WN (k MOD BSS); !, yyt->! WI (Class^.Class.Name);
!.! WI (Selector^.Child.Name); !->yyHead.yyIsDone! WN (k DIV BSS);
!) INCL (yyt->! WI (Class^.Class.Name); !.! WI (Selector^.Child.Name);
!->yyHead.yyIsDone! WN (k DIV BSS); !, ! WN (k MOD BSS); !); } else yyAbort (yyt);!
END;
FOR j := 1 TO InstCount DO
IF IsRelated (a, j, DP) THEN
GenCall (t, j);
END;
END;
IF IsElement (ORD ('X'), Options) AND (Trace IN t^.Class.Properties) THEN
@yyWriteEval (yyt, "@ WI (Selector^.Child.Name); !:! WI (Attribute^.Child.Name); @");@
IF (Action # ADR (Action)) AND NOT (Virtual IN Properties) THEN
EvalC.GenEvaluator (Action); !!
IF (Attribute^.Kind = Tree.Child) OR (Attribute^.Attribute.Type = itTree) THEN
!write! WI (itTree);
! (yyt->! WI (Name); !.! WI (Selector^.Child.Name);
!->! WI (Selector^.Child.Type); !.! WI (Attribute^.Child.Name); !)!
ELSE
!write! WI (Attribute^.Child.Type);
! (yyt->! WI (Name); !.! WI (Selector^.Child.Name);
!->! WI (Selector^.Child.Type); !.! WI (Attribute^.Child.Name); !) yyWriteNl ();!
END;
ELSE
!yyWriteNl ();!
END;
ELSIF IsElement (ORD ('Y'), Options) AND (Trace IN t^.Class.Properties) THEN
@yyWriteEval (yyt, "@ WI (Selector^.Child.Name); !:! WI (Attribute^.Child.Name); @");@
IF (Action # ADR (Action)) AND NOT (Virtual IN Properties) THEN
EvalC.GenEvaluator (Action);
END;
ELSE
IF (Action # ADR (Action)) AND NOT (Virtual IN Properties) THEN
EvalC.GenEvaluator (Action);
END;
END;
IF NOT (Input IN Properties) AND (Attribute^.Kind = Tree.Child) THEN
!{ register ! WI (itTree); ! yyr = yyt->! WI (Name); !.! WI (Selector^.Child.Name);
!->! WI (Selector^.Child.Type); !.! WI (Attribute^.Child.Name);
!; if (yyr->yyHead.yyParent == ! WI (iNoTree);
!) { yyr->yyHead.yyOffset = ! WN (Selector^.Child.Class^.Class.BitCount + Attribute^.Child.BitOffset);
!; yyr->yyHead.yyParent = yyt->! WI (Name); !.! WI (Selector^.Child.Name);
!; Init! WI (iModule); ! (yyr); } }!
END;
FOR i2 := 1 TO InstCount DO (* add group members *)
IF Instance^[i2].Action = Action THEN
WITH Instance^[i2] DO
IF Synthesized IN Properties THEN
k := ToBit0 (Class, i2);
! INCL (yyt->yyHead.yyIsComp! WN (k DIV BSS); !, ! WN (k MOD BSS); !);!
ELSIF Inherited IN Properties THEN
k := ToBit1 (Selector, i2 - AttrCount - Selector^.Child.InstOffset);
! INCL (yyt->! WI (Class^.Class.Name); !.! WI (Selector^.Child.Name);
!->yyHead.yyIsComp! WN (k DIV BSS); !, ! WN (k MOD BSS); !);!
END;
END;
END;
END;
! return;!
END;
END;
}; .
PROCEDURE CompBitInfo (t: Tree)
Class (..) :-
BitIndexSize := AttrCount;
MakeArray (BitIndex, BitIndexSize, TSIZE (tBitInfo));
i := 1;
gBitIndex := BitIndex;
ForallAttributes (t, CompBitInfo);
MaxBit := Max (i, MaxBit);
MaxInstCount := Max (InstCount, MaxInstCount);
.
Child (..) ;
Attribute (..) :-
({{Input, Test, Dummy}} * Properties = {{}});
INC (i);
gBitIndex^ [AttrIndex].ToBit := i;
gBitIndex^ [i].ToAttr := AttrIndex;
.
PROCEDURE CompInhIndices (t: Tree)
Class (..) :-
b: INTEGER;
{ FOR j := AttrCount + 1 TO InstCount DO
WITH Instance^ [j] DO
IF Inherited IN Properties THEN
b := ToBit2 (t, Selector, j);
Include (InhIndices, b);
INC (InhIndexCount^ [b]);
END;
END;
END;
}; .
PROCEDURE CountSynAttr (t: Tree)
Class (..) :-
NoCodeClass * Properties = {{}};
i <= BitCount;
{ WITH Instance^ [BitIndex^ [i].ToAttr] DO
IF ({Synthesized, Left} <= Properties) AND NOT (Test IN Properties) THEN
INC (n);
END;
END;
}; .
PROCEDURE TypeName (t: Tree)
Class (..) :-
NoCodeClass * Properties = {{}};
Trace IN Properties;
@"@ WI (Name); @",@
.
PROCEDURE GenS (t: Tree)
Class (..) :-
NoCodeClass * Properties = {{}};
i <= BitCount;
{ WITH Instance^ [BitIndex^ [i].ToAttr] DO
IF ({Synthesized, Left} <= Properties) AND NOT (Test IN Properties) THEN
Class := t;
IF n > 1 THEN
! case k! WI (Name); !:!
END;
FOR j := 1 TO InstCount DO
IF IsRelated (BitIndex^ [i].ToAttr, j, DP) THEN
GenCall (t, j);
END;
END;
GenEvalAttr (t, BitIndex^ [i].ToAttr);
IF NOT (Input IN Properties) AND (Attribute^.Kind = Tree.Child) THEN
!{ register ! WI (itTree); ! yyr = yyt->! WI (Name); !.! WI (Attribute^.Child.Name);
!; if (yyr->yyHead.yyParent == ! WI (iNoTree);
!) { yyr->yyHead.yyOffset = ! WN (BitCount + Attribute^.Child.BitOffset);
!; yyr->yyHead.yyParent = yyt; Init! WI (iModule); ! (yyr); } }!
END;
FOR i2 := 1 TO InstCount DO (* add group members *)
IF Instance^[i2].Action = Action THEN
WITH Instance^[i2] DO
IF Synthesized IN Properties THEN
k := ToBit0 (Class, i2);
IF k # i - 1 THEN
! INCL (yyt->yyHead.yyIsComp! WN (k DIV BSS); !, ! WN (k MOD BSS); !);!
END;
ELSIF Inherited IN Properties THEN
k := ToBit1 (Selector, i2 - AttrCount - Selector^.Child.InstOffset);
! INCL (yyt->! WI (Class^.Class.Name); !.! WI (Selector^.Child.Name);
!->yyHead.yyIsComp! WN (k DIV BSS); !, ! WN (k MOD BSS); !);!
END;
END;
END;
END;
IF n > 1 THEN
! break;!
END;
END;
END;
}; .
PROCEDURE GenE (t: Tree)
Class (..) :-
ToCompute: tSet;
{ GetIterator (t);
n := 0;
j := 2;
LOOP
IF j > InstCount THEN EXIT; END;
WITH Instance^ [j] DO
IF {Dummy, Output, Test} * Properties # {} THEN
IF (Test IN Properties) OR
({Synthesized, Left} <= Properties) OR
({Inherited, Right} <= Properties) OR
({Inherited, Left} <= Properties) AND
NOT (Input IN Properties) AND (Attribute^.Kind = Tree.Child) OR
({Synthesized, Right, Dummy} <= Properties) AND (Selector # Iterator) AND
(HasOutput IN Selector^.Child.Class^.Class.Properties) THEN
INC (n); EXIT;
END;
END;
END;
INC (j);
END;
IF (n = 0) AND ((Iterator = NoTree) OR NOT (HasOutput IN Iterator^.Child.Class^.Class.Properties)) THEN RETURN; END;
Class := t;
! case k! WI (Name); !:!
FOR j := 2 TO InstCount DO
WITH Instance^ [j] DO
IF {Dummy, Output} * Properties # {} THEN
IF ({Synthesized, Left} <= Properties) OR
({Inherited, Right} <= Properties) OR
({Inherited, Left} <= Properties) AND
NOT (Input IN Properties) AND (Attribute^.Kind = Tree.Child) THEN
GenCall (t, j);
ELSIF ({Synthesized, Right, Dummy} <= Properties) AND (Selector # Iterator) AND
(HasOutput IN Selector^.Child.Class^.Class.Properties) THEN
IF IsElement (ORD ('Z'), Options) AND (Trace IN t^.Class.Properties) THEN
@yyWriteVisit (yyt, "@ WI (Selector^.Child.Name); @"); @
END;
!yyE (yyt->! WI (Name); !.! WI (Selector^.Child.Name); !);!
IF IsElement (ORD ('Z'), Options) AND (Trace IN t^.Class.Properties) THEN
!yyVisitParent (yyt->! WI (Name); !.! WI (Selector^.Child.Name); !);!
END;
END;
END;
END;
END;
MakeSet (ToCompute, InstCount);
FOR i := 2 TO AttrCount DO
WITH Instance^ [i] DO
IF Test IN Properties THEN
FOR j := 2 TO InstCount DO
IF IsRelated (i, j, DP) THEN
IF {Synthesized, Inherited} * Instance^ [j].Properties # {} THEN
Include (ToCompute, j);
END;
END;
END;
END;
END;
END;
FOR i := 2 TO InstCount DO
WITH Instance^ [i] DO
IF ({Synthesized, Left, Output} <= Properties) OR
({Inherited, Right, Output} <= Properties) THEN
Exclude (ToCompute, i);
END;
END;
END;
WHILE NOT IsEmpty (ToCompute) DO
GenCall (t, Extract (ToCompute));
END;
ReleaseSet (ToCompute);
FOR i := 2 TO AttrCount DO
IF Test IN Instance^ [i].Properties THEN
GenEvalAttr (t, i);
END;
END;
IF (Iterator = NoTree) OR NOT (HasOutput IN Iterator^.Child.Class^.Class.Properties) THEN
!return;!
ELSE
IF IsElement (ORD ('Z'), Options) AND (Trace IN t^.Class.Properties) THEN
@yyWriteVisit (yyt, "@ WI (Iterator^.Child.Name); @"); @
END;
!yyt = yyt->! WI (Name); !.! WI (Iterator^.Child.Name); !; break;!
END;
}; .
PROCEDURE CompOutput (t: Tree)
Class (..) :-
NOT (HasOutput IN Properties);
Success := FALSE;
ForallAttributes (t, CompOutput);
ForallClasses (Extensions, CompOutput2);
Success;
INCL (Properties, HasOutput);
IsStable := FALSE;
.
Child (..) :-
(Output IN Properties) OR (HasOutput IN Class^.Class.Properties);
Success := TRUE;
.
Attribute (..) :-
({{Test, Output}} * Properties # {{}});
Success := TRUE;
.
PROCEDURE CompOutput2 (t: Tree)
Class (..) :-
HasOutput IN Properties;
Success := TRUE;
.
FUNCTION ToBit0 (Class, INTEGER) INTEGER
class, i ? RETURN class^.Class.BitIndex^ [i].ToBit - 1; .
FUNCTION ToBit1 (Child, INTEGER) INTEGER
Selector, i ? RETURN Selector^.Child.Class^.Class.BitIndex^ [i].ToBit - 1; .
FUNCTION ToBit2 (Class, Child, SHORTCARD) INTEGER
class, Selector, i RETURN _ ?
{ WITH Selector^.Child DO
RETURN class^.Class.BitCount + BitOffset +
Class^.Class.BitIndex^ [i - class^.Class.AttrCount - InstOffset].ToBit - 1;
END;
}; .
FUNCTION ToAttr (Class, INTEGER) INTEGER
LOCAL { VAR a: SHORTCARD; }
class, i RETURN _ ?
{ WITH class^.Class DO
FOR a := AttrCount + 1 TO InstCount DO
WITH Instance^ [a] DO
IF ({Input, Test, Dummy} * Properties = {}) AND
(ToBit2 (class, Selector, a) = i) THEN RETURN a; END;
END;
END;
END;
RETURN 0;
}; .